// Fill out your copyright notice in the Description page of Project Settings.


#include "AnimPlayer/Actions/ScaleAction.h"
#include "CurveWrappers/FloatCurveWrapper.h"

void FScaleAction::OnInit()
{
	FActionBase::OnInit();
	if (Layer.IsValid() && CurveWrapper.IsValid())
	{
		const float Value = CurveWrapper->GetValueByTime(0);
		Layer->DoScale(AnimTarget,ElementId, Value);
	}
}

void FScaleAction::OnBegin()
{
	FActionBase::OnBegin();
	if (Layer.IsValid() && CurveWrapper.IsValid())
	{
		const float Value = CurveWrapper->GetValueByTime(0);
		Layer->DoScale(AnimTarget,ElementId, Value);
	}
}

void FScaleAction::OnTick(const float DeltaTime)
{
	FActionBase::OnTick(DeltaTime);
	if (Layer.IsValid() && CurveWrapper.IsValid())
	{
		const float Value = CurveWrapper->GetValueByTime(Timer);
		Layer->DoScale(AnimTarget,ElementId, Value);
	}
}

void FScaleAction::OnEnd()
{
	FActionBase::OnEnd();
	if (Layer.IsValid() && CurveWrapper.IsValid())
	{
		const float Value = CurveWrapper->GetValueByTime(Duration);
		Layer->DoScale(AnimTarget,ElementId, Value);
	}
}
